package com.easy.test;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.junit.Test;

public class SpringMQ {

	@Test
	public void test() {
		
		//<a href=\"\/artist\/104331\/songlist\">  
		String regex = "\\/artist\\\\/[0-9]+\\\\\\/songlist";  
		Pattern pattern = Pattern.compile(regex);  
		Matcher matcher = pattern.matcher("${topicat123}");  
		if(matcher.find()){  
		    for(int i=0; i<=matcher.groupCount(); i++){  
		        System.out.println(i+":"+matcher.group(i));  
		    }  
		}  
		
		

	}
	@Test
	public void test2(){
		 String test = "$";
	       test = regMatch(test, "\\$\\{([\\w])\\}");      

	   }

	   public  String regMatch(String withinText, String regString) {
	        String code = null;
	        Pattern pattern = Pattern.compile(regString);
	        Matcher matcher = pattern.matcher(withinText);
	        if (matcher.find()) {
	            while (matcher.find()) {
	                code = matcher.group(1);
	                System.err.println("aaaa" + code);
	            }
	        }
	        return code;
	    }
}
